package service;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import model.User;

import org.springframework.transaction.annotation.Transactional;

import exceptions.DataException;
import exceptions.LeagueRestrictionException;
import exceptions.UserNotFoundException;

/**
 * Interface for the class UserServiceImpl
 * @author Andre Melo
 * @author Marcus Leite 
 * @author Sergio Danilo
 *
 */
@Transactional 
public interface UserService {
	
	/**
	 * Change any user attribute by a new received value
	 * @param id The ID of the user
	 * @param attribute The name of the attribute
	 * @param value The new value of the attribute
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 * @throws DataException
	 */
	 void changeUserAttribute(String id, String attribute, String value) throws IllegalAccessException, InvocationTargetException, DataException;
	
	/**
	 * Create an user with received parameteres
	 * @param firstName The fist name of the user
	 * @param lastName The last name of the user
	 * @param homePhone The home phone of the user
	 * @param workPhone The work phone of the user
	 * @param cellPhone The cell phone of the user
	 * @param email The email of the user
	 * @param picture The picture of the user
	 * @param password The password of the user
	 * @param roles The roles of the user
	 * @return The ID of the user
	 * @throws DataException
	 */
	 Integer createUser(String firstName, String lastName, String homePhone, String workPhone, String cellPhone, String email,
			                  String picture, String password, String role) throws DataException;
	
	/**
	 * Delete the user by the ID
	 * @param id The ID of the user
	 * @return The removed user
	 * @throws LeagueRestrictionException
	 */
	 User delete(Integer id) throws LeagueRestrictionException;

	/**
	 * Remove all existing users
	 */
	 void deleteAll();
	
	/**
	 * Find the user by the e-mail
	 * @param email The e-mail of the user
	 * @return The required user
	 * @throws UserNotFoundException
	 */
	 User findByEmail(String email) throws UserNotFoundException;
	
	/**
	 * Find the user by the ID
	 * @param id The ID of the user
	 * @return The required user
	 */
	 User findById(Integer id);
	
	/**
	 * Find and list the user(s) by last name
	 * @param lastName The last name of the user(s)
	 * @return All user(s) that have this last name 
	 * @throws UserNotFoundException
	 */
	 List<User> findByLastName(String lastName) throws UserNotFoundException;
	
	/**
	 * Get some user attribute
	 * @param id The ID of the user
	 * @param attribute The name of the attribute
	 * @return The required attribute
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 * @throws NoSuchMethodException
	 */
	 String getUserAttribute(String id, String attribute) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;
	
	/**
	 * Method that returns true if user exist, false otherwise
	 * @param userId The ID of the user
	 * @return True if user exist, false otherwise
	 */
	 boolean isAnExistentUser(Integer userId);

	/**
	 * List all first name of the users
	 * @return All first name of the users
	 */
	 List<User> listAll();

	/**
	 * Save the user
	 * @param user The ID of the user
	 * @return
	 */
	 Integer save(User user);

	/**
	 * Update the user attribute
	 * @param user The new user
	 */
	 void update(User user);
}
